package com.nangle.managehost.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;

import com.nangle.managehost.db.SDCardSQLiteOpenHelper;

/**
 * SQLite数据库的帮助类
 *
 * 该类属于扩展类,主要承担数据库初始化和版本升级使用,其他核心全由核心父类完成
 *
 * @author shimiso
 *
 */
public class DataBaseHelper extends SDCardSQLiteOpenHelper {

	public DataBaseHelper(Context context, String name, CursorFactory factory,
						  int version) {
		super(context, name, factory, version);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL("CREATE TABLE [patient] ([_id] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,[name] TEXT, [sex] INTEGER, [age] INTEGER, [nursingGrade] INTEGER, [diagnosis] NVARCHAR,[diet] NVARCHAR,[admission]NVARCHAR, [bed] INTEGER,[ye] INTEGER,[wen] INTEGER,[shu] INTEGER,[guan] INTEGER,[jia] INTEGER);");
		db.execSQL("CREATE TABLE [bed]  ([_id] INTEGER NOT NULL  PRIMARY KEY AUTOINCREMENT,[bednumber] INTEGER,[nurse_name] TEXT,[roomnumber] INTEGER,[type] INTEGER);");
		db.execSQL("CREATE TABLE [room]  ([_id] INTEGER NOT NULL  PRIMARY KEY AUTOINCREMENT,[roomnumber] INTEGER,[responsibility_nurse] TEXT,[type] INTEGER,[doctorLeader] TEXT,[nurseLeader] TEXT,[doctor] TEXT);");
		db.execSQL("CREATE TABLE [nurse]  ([_id] INTEGER NOT NULL  PRIMARY KEY AUTOINCREMENT,[name] TEXT,[age] INTEGER,[title] TEXT);");
		db.execSQL("CREATE TABLE [doctor]  ([_id] INTEGER NOT NULL  PRIMARY KEY AUTOINCREMENT,[name] TEXT,[age] INTEGER,[title] TEXT);");


	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

	}

	@Override
	public void onOpen(SQLiteDatabase db) {
		super.onOpen(db);
	}
}
